<%@ page import="com.capgemini.core.AjaxResponse" %>
<%@ page import="com.capgemini.commons.JsonUtil" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="org.slf4j.LoggerFactory" %>
<%@ page import="org.slf4j.Logger" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page trimDirectiveWhitespaces="true" %>
<%
  Boolean isLog =  (Boolean)request.getAttribute("logError");
  if(isLog == null){
    Logger log = LoggerFactory.getLogger(this.getClass());
    log.error("", pageContext.getException());
  }

  boolean isAjax = StringUtils.equalsIgnoreCase(request.getHeader("custom-request-method"), "ajax");

  if(isAjax) {
    AjaxResponse ajaxResponse = new AjaxResponse();

    ajaxResponse.setSuccess(false);
    ajaxResponse.setErrorCode("500");
    ajaxResponse.setMessage("系统出现未知异常，请刷新页面重试或联系管理员！");

    String jsonStr = JsonUtil.getJson(ajaxResponse);

    response.setContentType("application/json;charset=UTF-8");

    out.print(jsonStr);
  }else{
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
</head>
<body>
<div style="font-size:24px; font-weight:bold; padding:50px; background: #FFF;">
  500　Server Error<BR/>
  系统出现未知异常，请刷新页面重试或联系管理员！
</div>
</body>
</html>
<%}%>